#include <iostream>
using namespace std;

int S[1005];
 
int getf(int x) {
    if (S[x] == x) return x;
    return S[x] = getf(S[x]);
}
 
void merge(int x, int y) {
    int xf = getf(x), yf = getf(y);
    if (xf != yf) {
        S[xf] = yf;
        S[x] = yf;
    }
}

int main() {
	int n, m, q, a, b;
	cin >> n >> m >> q;
	for (int i = 0; i <= n; ++i) {
		S[i] = i;
	}

	for (int i = 1; i <= m; ++i) {
		cin >> a >> b;
		merge(a, b);
	}

	for (int i = 1; i <= q; ++i) {
		cin >> a >> b;
		if (getf(a) == getf(b)) {
			cout << "Y" << endl;
		} else {
			cout << "N" << endl;
		}
	}
	return 0;
}